﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-12-27 15:13:08Z</CreationDate>
</File>
*/
#endregion

using Microsoft.Practices.ServiceLocation;

namespace Outcoder.InversionOfControl.Containers.SimpleContainer
{
	/* TODO: [DV] Comment. */
	public static class SimpleServiceLocatorExtensions
	{
		static SimpleServiceLocatorAdapter locatorAdapter;
		static bool Initialized { get; set; }

		public static void InitializeContainer(this IContainer container)
		{
			ArgumentValidator.AssertNotNull(container, "container");
			locatorAdapter = new SimpleServiceLocatorAdapter(container);
			container.Register<IContainer>(container);
			container.Register<IDependencyRegistrar>(new SimpleContainerRegistrar());
			ServiceLocator.SetLocatorProvider(() => locatorAdapter);
			container.Register<IServiceLocator>(ServiceLocator.Current);
			Initialized = true;
			Dependency.Initialized = true;
		}

		public static bool IsInitialized(this IContainer adapter)
		{
			return Initialized;
		}
	}
}
